package com.vdf.sisconsolid.timer;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class SisconsolidTimer {
 
    public static void main(String[] args) {
 
    	Timer timer = new Timer("SisconsolidTimer");
 
        SisconsolidTask t = new SisconsolidTask();
 
        timer.schedule(t, 0, 1000 * 60 ); // each three hours
  
    }
}
 
class SisconsolidTask extends TimerTask {
    //times member represent calling times.
    private int times = 0;
 
 
    public void run() {
        times++;
        if (times <= 5) {
            System.out.println("I'm alive...");
        } else {
            System.out.println("Timer stops now...");
 
            //Stop Timer.
            this.cancel();
        }
    }


private boolean isMoonday() {
	Calendar c = Calendar.getInstance();
	c.setTime(new Date());
	int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
	return dayOfWeek == Calendar.MONDAY;
}

private boolean isMonthFirstDay() {
	Calendar c = Calendar.getInstance();
	c.setTime(new Date());
	int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
	return dayOfMonth == 1;
}
	
}